<%@ page import="com.wuchao.service.serviceimpl.ServiceImpl" %><%--
  Created by IntelliJ IDEA.
  User: 吴超
  Date: 2022/4/14
  Time: 13:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    request.setCharacterEncoding("utf-8");
    ServiceImpl service = new ServiceImpl();
    String op=(String)request.getParameter("op");
    if(op!=null){
        String name=request.getParameter("name");
        String pwd=request.getParameter("pwd");//表单默认传值String
        if(op.equals("load")){
            int loading = service.isLoading("select count(1) from t143 where name=? and age=?", name, pwd);
            if(loading>0){//永远看不到，不要在这里写输出语句，还有一旦转走、响应那就走，剩余代码
                //会话 设置1分钟免登录
                session.setMaxInactiveInterval(60);
                session.setAttribute("login",name);
                //cookie 用来做非法入侵的
           /*     Cookie cookie=new Cookie("login",name);
                cookie.setMaxAge(45);
                response.addCookie(cookie);//只能往后页面查询*/
                request.getRequestDispatcher("main.jsp").forward(request,response);
            }else{
                response.sendRedirect("load.jsp?isloading=false");
            }
        }else if(op.equals("register")){
            int pwd1=Integer.parseInt(pwd);
            int registering = service.update("insert t143(name,sex,age) values(?,'男',?) ", name, pwd1);
            if(registering>0){//永远看不到，不要在这里写输出语句，还有一旦转走、响应那就走，剩余代码
                request.getRequestDispatcher("load.jsp?registering1=true").forward(request,response);
            }else{
                response.sendRedirect("load.jsp?registering2=false");
            }
        }else{

        }

    }else{
        response.sendRedirect("load.jsp?illegal=true");
    }





%>

</body>
</html>
